const ErrorDecorator:MethodDecorator = (target:Object, propertyKey:string | symbol,descriptor:PropertyDescriptor) => {
    const method = descriptor.value;
    descriptor.value = () => {
        try {
            method();
        } catch (error:any) {
            console.log(`%c${error.message}`,'color:red;font-size:16px;')
        }
    }
}

class User{
    @ErrorDecorator
    public find(){
        throw Error("用户查找失败")
    }

    @ErrorDecorator
    public add(){
        throw Error("用户添加失败")
    }
}

const user = new User();
user.find();
user.add();
